﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class ModifierCarte : Form
    {
        public Bordereau_Form_Modif_lot modifeirborderaeuForm = new Bordereau_Form_Modif_lot();

        private Carte carte = new Carte();

        public Carte Carte
        {
            get { return carte; }
            set { carte = value; }
        }

        public Bordereau_Form_Modif_lot bordereauFormModiflot { get; set; }
        public ModifierCarte()
        {
            InitializeComponent();
            RAMEDEntities1 context = SingletonContext.GetContext();
            comboBoxcentresante.DataSource = context.Centre_sante;
            comboBoxcentresante.DisplayMember = "nom_centre_sante";
            comboBoxcentresante.ValueMember = "id_centre_sante"; 
        }

        private void btnenregistrer_Click(object sender, EventArgs e)
        {
            RAMEDEntities1 Context = SingletonContext.GetContext();
            carte.Prenom_benefi = txtprenom.Text;
            carte.Nom_benefi = txtnom.Text;
            carte.IPCM =  txtipcm.Text;
            carte.CIN_benefi = txtcin.Text;
            carte.Centre_sante = (Centre_sante)comboBoxcentresante.SelectedItem;
            modifeirborderaeuForm.mettreAjourFormGridView();
            
            Context.SaveChanges();
            
            this.Dispose();
        }

        public  void InitialiserChamps()
        {

            txtprenom.Text  =  carte.Prenom_benefi;
            txtnom.Text  =  carte.Nom_benefi;
            txtcin.Text =   carte.IPCM.ToString() ;
            txtipcm.Text = carte.CIN_benefi;
            comboBoxcentresante.SelectedValue = carte.id_centre_sante;
        }

        public modifeirborderaeuForm modifierBordereauForm { get; set; }
    }
}
